home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / controls / scrollClasses / ScrollThumb.as < prev   
Text File  |  2014-03-27  |  3KB  |  106 lines

  1. package mx.controls.scrollClasses
  2. {
  3.    import flash.events.MouseEvent;
  4.    import flash.geom.Point;
  5.    import mx.controls.Button;
  6.    import mx.core.mx_internal;
  7.    import mx.events.ScrollEventDetail;
  8.    
  9.    use namespace mx_internal;
  10.    
  11.    public class ScrollThumb extends Button
  12.    {
  13.       
  14.       mx_internal static const VERSION:String = "3.0.0.0";
  15.        
  16.       
  17.       private var lastY:Number;
  18.       
  19.       private var datamin:Number;
  20.       
  21.       private var ymax:Number;
  22.       
  23.       private var ymin:Number;
  24.       
  25.       private var datamax:Number;
  26.       
  27.       public function ScrollThumb()
  28.       {
  29.          super();
  30.          explicitMinHeight = 10;
  31.          stickyHighlighting = true;
  32.       }
  33.       
  34.       private function stopDragThumb() : void
  35.       {
  36.          var _loc1_:ScrollBar = ScrollBar(parent);
  37.          _loc1_.isScrolling = false;
  38.          _loc1_.dispatchScrollEvent(_loc1_.oldPosition,ScrollEventDetail.THUMB_POSITION);
  39.          _loc1_.oldPosition = NaN;
  40.          systemManager.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler,true);
  41.          systemManager.stage.removeEventListener(MouseEvent.MOUSE_MOVE,stage_mouseMoveHandler);
  42.       }
  43.       
  44.       override protected function mouseDownHandler(param1:MouseEvent) : void
  45.       {
  46.          super.mouseDownHandler(param1);
  47.          var _loc2_:ScrollBar = ScrollBar(parent);
  48.          _loc2_.oldPosition = _loc2_.scrollPosition;
  49.          lastY = param1.localY;
  50.          systemManager.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler,true);
  51.          systemManager.stage.addEventListener(MouseEvent.MOUSE_MOVE,stage_mouseMoveHandler);
  52.       }
  53.       
  54.       private function mouseMoveHandler(param1:MouseEvent) : void
  55.       {
  56.          if(ymin == ymax)
  57.          {
  58.             return;
  59.          }
  60.          var _loc2_:Point = new Point(param1.stageX,param1.stageY);
  61.          _loc2_ = globalToLocal(_loc2_);
  62.          var _loc3_:Number = _loc2_.y - lastY;
  63.          _loc3_ += y;
  64.          if(_loc3_ < ymin)
  65.          {
  66.             _loc3_ = ymin;
  67.          }
  68.          else if(_loc3_ > ymax)
  69.          {
  70.             _loc3_ = ymax;
  71.          }
  72.          var _loc4_:ScrollBar;
  73.          (_loc4_ = ScrollBar(parent)).isScrolling = true;
  74.          $y = _loc3_;
  75.          var _loc5_:Number = _loc4_.scrollPosition;
  76.          var _loc6_:Number = Math.round((datamax - datamin) * (y - ymin) / (ymax - ymin)) + datamin;
  77.          _loc4_.scrollPosition = _loc6_;
  78.          _loc4_.dispatchScrollEvent(_loc5_,ScrollEventDetail.THUMB_TRACK);
  79.          param1.updateAfterEvent();
  80.       }
  81.       
  82.       override mx_internal function buttonReleased() : void
  83.       {
  84.          super.buttonReleased();
  85.          stopDragThumb();
  86.       }
  87.       
  88.       private function stage_mouseMoveHandler(param1:MouseEvent) : void
  89.       {
  90.          if(param1.target != stage)
  91.          {
  92.             return;
  93.          }
  94.          mouseMoveHandler(param1);
  95.       }
  96.       
  97.       mx_internal function setRange(param1:Number, param2:Number, param3:Number, param4:Number) : void
  98.       {
  99.          this.ymin = param1;
  100.          this.ymax = param2;
  101.          this.datamin = param3;
  102.          this.datamax = param4;
  103.       }
  104.    }
  105. }
  106.